package com.example.choupaiapp.common.util;

import android.content.Context;

/**
=================================================
*作者: lty
*邮箱: remebermelula@aliyun.com
*时间: 2017-11-24
*类名:  FileUtil .java
*版本: V 1.0
*描述:全局上下文工具类
===============================================
*/

public class ContextUtil {

    private static Context context;

    private ContextUtil() {
        throw new UnsupportedOperationException("u can't instantiate me...");
    }

    /**
     * 初始化工具类
     *
     * @param context 上下文
     */
    public static void init(Context context) {
        ContextUtil.context = context.getApplicationContext();
    }

    /**
     * 获取ApplicationContext
     *
     * @return ApplicationContext
     */
    public static Context getContext() {
        if (context != null) return context;
        throw new NullPointerException("u should init first");
    }
}